<template>
	<view class="content">
		<view class="pT10 pL15 pR10 pB5">
			身份证信息
		</view>
		
		<view class="input-group">
			<view class="input-row border">
				<text class="title">访客姓名：</text>
				<!-- <div class="cvc"> -->
				<!-- {{ namex }} -->
					<m-input type="text" name="" placeholder="请输入访客姓名" v-model="namex" />
				<!-- </div> -->
			</view>		
		<!-- 	<view class="input-row border">
				<text class="title">身份证号：</text>
			
				<m-input type="text" name="" placeholder="请输入身份证号" v-model="shenfenx" />
				
			</view> -->
			<view class="input-row border">
				<text class="title">手机号码：</text>
				<!-- <div class="cvc"> -->
				<!-- {{ shenfenx }} -->
				<text style="line-height: 45px;margin-left: 5px;">{{shouji}}</text>
				<!-- </div> -->
			</view>
		</view>
		
		<view :class="showtype?'btn-row2':'btn-row'">
			<view class="w90 mauto pT10 pB10">
				<button type="primary" class=" " @tap="register">下一步</button>
			</view>
		</view>
	</view>
</template>
<script>
var _self;
import mInput from '../../components/m-input.vue';
import {idcardupcache,usereasyreg,userinfo} from '../../common/api/user.js';

import request from '../../common/vmeitime-http/requstx.js';
export default {
	components: {
		mInput
	},
	data() {
		return {			
			shenfenx: '',
			namex: '',
			idcard_date_type:"",
			showtype:"",
			shouji:"",
		};
	},
	onLoad:function(enevt) {
		_self = this;
		if(enevt.type){
			var showtype='chidcard';
			this.showtype='chidcard';
		}else{
			var showtype='';
			this.showtype='';
		}
		if(enevt.shouji){
			this.shouji=enevt.shouji
		}else{
			userinfo().then(res=>{
				this.shouji = res.data.data.mobile;
			})
		}
	},
	onShow() {
	},
	methods: {
		register:function(e) {
			/**
			 * 客户端对账号信息进行一些必要的校验。
			 * 实际开发中，根据业务需要进行处理，这里仅做示例。
			 */
			// uni.navigateTo({
			// 	url: '/pages/shouquan/renlian'
			// });
			// return
			
			
			if (this.namex.length == '') {
				uni.showToast({
					icon: 'none',
					title: '姓名不能为空'
				});
				return;
			}
			// if (this.shenfenx.length == '') {
			// 	uni.showToast({
			// 		icon: 'none',
			// 		title: '身份证号不能为空'
			// 	});
			// 	return;
			// }
			// if (this.shenfenx.length != 18) {
			// 	uni.showToast({
			// 		icon: 'none',
			// 		title: '身份证号不正确，请重新输入'
			// 	});
			// 	return;
			// }
			
			usereasyreg({
				u_name: this.namex,
				identitycard: this.shenfenx,				
			}).then(res=>{
				if (res.data.code == 200) {
					sessionStorage.setItem("tokensession",'YES');
					sessionStorage.setItem("isloadingget",'YES');
					// window.location.replace('/wap/#/pages/shouquan/renliansuccessful?type=yuyue')
				uni.reLaunch({
					url:'/pages/shouquan/idcardsuccessful?type=yuyue'
				});
				}else{
					console.log(res.data.message);					
				}
			})
			
		},
		sendCode: function() {
			this.codeBtn.waitingCode = true;
			this.codeBtn.count = this.seconds;
			this.codeBtn.text = this.codeBtn.count + 's';

			let countdown = setInterval(() => {
				this.codeBtn.count--;
				this.codeBtn.text = this.codeBtn.count + 's';
				if (this.codeBtn.count < 0) {
					clearInterval(countdown);
					this.codeBtn.text = '重新发送';
					this.codeBtn.waitingCode = false;
				}
			}, 1000);

			console.log(221);
			const data = {
				username: this.captchaImg
			};
			request({
				url: 'user/send',
				method: 'POST',
				data: {
					mobile: this.captchaImg
				},
				success: function(res) {
					console.log(res.data);
				}
			});
		},
		gotoLogin: function() {
			uni.navigateTo({
				url: 'login'
			});
		}
	},
	computed: {
		disableCodeBtn: function() {
			return this.codeBtn.waitingCode || this.captchaImg.length < 11;
		}
	}
};
</script>
<style scoped>
.cvc {
	line-height: 38px;
}

.content {
	display: flex;
	flex: 1;
	flex-direction: column;
	background-color: #efeff4;
	padding-bottom: 100px;
	
}
.sb {
	font-size: 15px;
	width: 104px;
	margin-right: 10px;
	margin-top: 5px;
	margin-bottom: 5px;
}

img {
	height: 300upx !important;
}

view {
	font-size: 28upx;
}

.grace-idcard-main {
	margin: 20upx 30upx;
}

.grace-idcard-desc {
	line-height: 2em;
	background: #ffffff;
	padding: 20upx;
	border-radius: 10upx;
}

.grace-idcard-text {
	line-height: 2em;
	margin-top: 30upx;
}

.grace-idcard-items {
	background: #ffffff;
	padding: 10upx 0;
	display: flex;
	/* margin: 30upx 0; */
	border-radius: 10upx;
	align-items: flex-start;
}

.grace-idcard-uper-btn {
	width: 576upx;
	height: 350upx;
	margin: 0 auto;
	background: #f1f1f1;
	padding-bottom: 10upx;
	border-radius: 10upx;
	text-align: center;
}

.grace-idcard-uper-btn .img {
	width: 500upx;
	height: 100upx;
	margin: 0 auto;
	margin-top: 30upx;
}

.grace-idcard-uper-btn .img image {
	width: 500upx;
	height: 300upx !important;
}

.grace-idcard-uper-btn .text {
	width: 100%;
	margin-top: 10upx;
	text-align: center;
	line-height: 2em;
}

.grace-idcard-preview {
	width: 50%;
	margin: 0 30upx;
}

.grace-idcard-preview image {
	width: 100%;
	height: 300upx !important;
}
.btn-row{    position: fixed; width: 100%;bottom: 0;left: 0;background: #fff;}
.btn-row2{    position: fixed; width: 100%;bottom: 50px;left: 0;background: #fff;}
.noimginshow .img{opacity: 0.5;}
.noimginshow .text{color: #06C;}
.noimginshow .textdiv{    position: absolute; width: 100%; text-align: center; left: 0;}
.deltrash{position: absolute; text-align: center; right: 10upx;top:10upx;background-color: #fff;}
</style>
